package com.craney.aboutVideo
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.media.Video;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.utils.Timer;
	
	public class TestVideo
	{
		private var timer:Timer = new Timer(2000, 1);
		private var timeContinue:Timer = new Timer(2000, 1);
		
		public function TestVideo(ps:Sprite)
		{
			var connetion:NetConnection = new NetConnection();
			connetion.connect(null);
			
			var stream:NetStream = new NetStream(connetion);
			stream.client = {onMetaData:internalFunction};
			
			var video:Video = new Video();
			video.attachNetStream(stream);
			
			ps.addChild(video);
			
			timer.addEventListener(TimerEvent.TIMER_COMPLETE, interComplete);
			timeContinue.addEventListener(TimerEvent.TIMER_COMPLETE, playVideo);
			
			stream.play("LeeJian.mp4");
			
			function playVideo(event:Event):void
			{
				trace("It's starting again!");
				stream.play("LeeJian.mp4");	
			}
			
			function interComplete(event:Event):void
			{
				trace("Just pause!");
				stream.pause();
				timeContinue.start();
			}
			
			function internalFunction(obj:Object):void
			{
				trace("timer.currentCount=" + timer.currentCount);
				trace("timer.repeatCount=" + timer.repeatCount);
				timer.start();
				trace("This is in metaData")
			}
			
		}

	}
}